package gui.parta;

import java.util.HashMap;
import java.util.Map;

/**
 * Part A.2-1
 *
 * @author guodd
 * @version 1.0 use jdk 1.8
 */
public class DataPacketException extends Exception {
    Map<Integer, DataPacketException> errors = new HashMap<>();
    int id;

    // Part A.2-1-a
    public DataPacketException(int id, String message) {
        super(message);
        this.id = id;
    }

    // Part A.2-1-b
    public DataPacketException getExceptionById(int id) {
        return errors.get(id);
    }

    // Part A.2-1-c
    @Override
    public String toString() {
        return this.getMessage() + "," + super.getMessage();
    }
}
